/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-10-18
 * Time:9:48
 */
class MyArray2<T>{
    public T[] array=(T[])new Object[10];//one
    public T getPos(int pos){
        return this.array[pos];
    }
    public void setVal(int pos,T val){
        this.array[pos]=val;
    }
    public T[] getArray(){
        return array;
    }
}
public class TestDemo1 {
    public static <T> void print(T str){
        System.out.println(str);
    }
    public static void fun(MyArray2<?> temp){
        System.out.println(temp.getPos(0));
    }
    public static void main(String[] args) {
        MyArray2<Integer> myArray=new MyArray2<>();//two
        myArray.setVal(0,10);
        myArray.setVal(1,12);
        int ret=myArray.getPos(0);//three
        System.out.println(ret);
       // Integer[] arr=myArray.getArray();
        print(23);
        print(3.4);
        print("chenlian");
        //代码编译报错，此时因为在注释2处指定类当前的类型，此时的注释4处，编译器会在存放元素的时候帮助我们进行类型检查
       // myArray.setVal(2,"bit");//four
        fun(myArray);

    }
}
